<template>
  <input v-show="false" ref="input" type="file" @change="handleInputChange" />
</template>
<script>
import { postImportExcel } from '@/api/customerApi.js';
export default {
  props: {
    accept: {
      type: Array,
      default: () => ['application/vnd.ms-excel', '.xls'],
    },
    visible: {
      type: [Boolean],
      default: false,
    },
  },
  data() {
    return {};
  },
  computed: {},
  methods: {
    uploader() {
      console.log(this.$refs, 'sdfsdfsdfsdfdsfsdfdsfs');
      this.$refs.input?.click && this.$refs.input?.click();
    },
    async handleInputChange(e) {
      console.log('e: ', e);
      const file = e.target.files[0];
      const name = e.target.files[0].name;

      const result = await postImportExcel(file).finally(() => {
        e.target.value = null;
      });
      
      if (result.data.code === 0) {
        this.$emit('load-table-list');
      }
    },
    handleCancel() {
      this.$emit('update:visible', false);
    },
    handleOk() {},
  },
};
</script>

<style lang="less" scoped>
.co {
  color: red;
}
</style>
